The Sound Manager maintains a sound channel record to store information about each sound channel that you allocate directly by calling the SndNewChannel function or indirectly by passing a NIL channel to a high-level Sound Manager routine like the SndPlay function. The SndChannel data type defines a sound channel record.
TYPE SndChannel =
PACKED RECORD
nextChan: SndChannelPtr; {pointer to next channel}
firstMod: Ptr; {used internally}
callBack: ProcPtr; {pointer to callback procedure}
userInfo: LongInt; {free for application's use}
wait: LongInt; {used internally}
cmdInProgress: SndCommand; {used internally}
flags: Integer; {used internally}
qLength: Integer; {used internally}
qHead: Integer; {used internally}
qTail: Integer; {used internally}
queue: ARRAY[0..stdQLength-1] OF SndCommand;
END;
The only field of the sound channel record that you are likely to need to access directly is the userInfo field. This field is useful if you need to pass a value to a Sound Manager callback procedure or completion routine. For example, you might pass the value stored in the A5 register so that your callback procedure can access your application's global variables. Or, you might store a handle to sound data here so that a routine that disposes of an allocated channel can also release the sound data that the channel played.
In rarer instances, you might need to access the callBack field of the sound channel record directly. Ordinarily, you set this field by specifying a callback procedure when you call the SndNewChannel function. However, you can change the callback procedure associated with a channel by changing this field directly. The Sound Manager will then execute the procedure you specify in this field whenever the channel processes a callBackCmd command.
You should not attempt to manipulate all open sound channels by using the nextChan field to walk the sound channel queue. The queue might contain channels opened by other applications. If you need to perform some operation on all sound channels that your application has allocated, you should maintain your own data structure that keeps track of your application's channels.
| Previous | Chapter contents | Chapter top | Section top | Next |